{extend name="_container/add"}

{block name="content"}
<link rel="stylesheet" href="/static/admin/plugin/layuiExtend/modules/css/formSelects.css">
<input type="hidden" name="id" value="{$r.id}">
<div class="layui-form-item" style="">
    <label class="layui-form-label">角色名称</label>
    <div class="layui-input-inline">
        <input class="layui-input"  name="name" value="{$r.name}">
    </div>
    <div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item" style="">
    <label class="layui-form-label">菜单选择</label>
    <div class="layui-input-inline">
        <div id="tree"></div>
    </div>
    <div class="layui-form-mid layui-word-aux"></div>
</div>
<div class="layui-form-item" style="">
    <label class="layui-form-label">权限选择</label>
    <div class="layui-input-inline">
        <select name="access[ ]" class="select2" lay-ignore multiple style="width: 100%">
            {foreach $accessArr as $access}
            <option value="{$access.id}" {$access.checked?'selected':''}>{$access.name}</option>
            {/foreach}
        </select>
    </div>
    <div class="layui-form-mid layui-word-aux"></div>
</div>
{/block}

{block name="js"}
<script>
    function save_form3(obj){
        save_form2(obj);
        return false;
    }
    layui.config({
        base: '/static/admin/plugin/layuiExtend/modules/js/' //静态资源所在路径
    });
    layui.use(['form','jquery','authtree','jquery'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        var authtree = layui.authtree;
        var trees = authtree.listConvert( {:json_encode($nodes)} , {
            primaryKey: 'id'
            , startPid: 0
            , parentKey: 'pid'
            , nameKey: 'name'
            , valueKey: 'id'
            , checkedKey: 'checked'
        });
        authtree.render('#tree', trees, {
            inputname: 'node[ ]',
            layfilter: 'tree',
            autowidth: true,
        });

    })
</script>
{/block}

{/extend}